package cn.nuc.project1;

public class LzzTryConcurrency {

    public static void main(String[] args) {
        // 1.通过jdk1.8之前的匿名内部类方式
        new Thread(){
            @Override
            public void run() {
                super.run();
                studyConcurrency();
            }
        }.start();
        // 2.jdk1.8现在的Lambda方式
        // new Thread(() -> {enjoyMusic();}).start();
        // 对象方法引用
        new Thread(LzzTryConcurrency::enjoyMusic).start();

    }
    // 学习高并发知识
    private static void studyConcurrency(){
        while(true){
            System.out.println("study concurrency!");
            try {
                Thread.sleep(1000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
    //享受音乐
    private static void enjoyMusic(){
        while (true){
            System.out.println("enjoy music");
            try {
                Thread.sleep(1000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

